package com.twu.biblioteca.model.menu.actions;

import com.twu.biblioteca.model.Customer;
import com.twu.biblioteca.model.menu.Menu;
import com.twu.biblioteca.model.menu.MenuAction;

public class LoginAction extends MenuAction {

    public LoginAction(boolean needsLogin) {
        super(needsLogin);
    }

    @Override
    public boolean performAction(Menu menu, String[] args) {

        for (Customer customer : menu.getLibrary().getCustomers()) {
            if (customer.getLibraryNumber().equals(args[0]) && customer.getPassword().equals(args[1])) {
                menu.setLoggedInCustomer(customer);
                return true;
            }
        }
        return false;

    }
}
